<?php

/**
 * One ring to rule them all
 *
 * Class between frontside & backside.
 * Everything goes through this class.
 *
 * @author Jiles
 */

class Controller {
    
    private $dbcon;
    private $facebook;
    
    private $usercontroller;
    private $moviecontroller;
    private $facebookcontroller;

    public function  __construct()
    {
        $this->dbcon = new databaseconnection(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT);
        
        
        $this->moviecontroller = new Moviecontroller($this->dbcon);
        $this->facebookcontroller = new Facebookcontroller($this->dbcon);
        $this->usercontroller = new Usercontroller($this->dbcon, $this->facebookcontroller, $this->moviecontroller);
	
    }
    
    public function getUserController(){
    	
    	return $this->usercontroller;
    
    }
    /**
    *	Print movies
    *	
    *	if user is logged in: check off movies already seen
    *	if no user: just show movies
    */
    public function printMovies(){
    	$userid = $this->facebookcontroller->getUser();
    	
    	if( $userid != 0)
    	{
    		return $this->moviecontroller->printMovies($userid);
    	}
    	else
    		return $this->moviecontroller->printMovies();
    }
    
    public function getMovieController(){
    	
    	return $this->moviecontroller;
    
    }
    
    public function getFacebookController(){
    	
    	return $this->facebookcontroller;
    
    }
    
    
    
  


}
?>
